<?php

namespace App\Services;

class SingleService
{
    /**
     * @var array
     */
    protected static $instance = [];

    /**
     * 返回当前类单例对象
     *
     * @return SingleService
     */
    public static function getInstance()
    {
        $class_name = get_called_class();

        if (!isset(static::$instance[$class_name])) {
            static::$instance[$class_name] = new $class_name;
        }
        return static::$instance[$class_name];
    }
}
